﻿using Microsoft.Extensions.Configuration;
using System;

namespace ConfigurationEnvironmentVariablesDemo
{
    class Program
    {
        static void Main(string[] args)
        {
            var builder = new ConfigurationBuilder();
            //builder.AddEnvironmentVariables();

            //var configurationRoot = builder.Build();
            //Console.WriteLine($"key1:{configurationRoot["key1"]}");

            //#region 分层键
            //var section = configurationRoot.GetSection("SECTION1");
            //Console.WriteLine($"KEY3:{section["KEY3"]}");

            //var section2 = section.GetSection("SECTION2");
            //Console.WriteLine($"SECTION2:KEY3:{section2["KEY3"] }");
            //#endregion

            #region 前缀过滤
            builder.AddEnvironmentVariables("XIAO_");
            var config = builder.Build();
            Console.WriteLine($"key1:{config["key1"]}");
            Console.WriteLine($"KEY1:{config["KEY1"]}");
            Console.WriteLine($"KEY2:{config["KEY2 "]}");
            #endregion 
        }
    }

  
}
